Repository navigation
Add support for freebsd and various small fixes - #16
Merged
Merged
Conversation
Empty parentheses declare an unspecified argument list in C; use (void) for the functions that take no arguments so the compiler checks call sites. No behavioural change. DEBUG_PRINT was declared variadic (fmt, ...) but its body never expands the arguments, and invoking a variadic macro with no variadic argument is not portable under -pedantic-errors. It is only ever used with a bare format string, so drop the variadic parameter. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Most applications expect a writable /tmp. Mount a tmpfs there in mount_special_fs; urunit itself does not depend on it, so a failure is logged but not fatal. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Declare the platform-specific hooks in common.h (setup_console, remount_root_rw, get_boot_var, read_raw_device, configure_network) and the struct net_config they use, and provide their Linux implementations: no-ops where the kernel already handles the concern (console, remount, boot vars, network via ip=). This is the seam FreeBSD support plugs into. The configuration may be handed to the guest as a tiny (virtio) block or character device rather than a regular file. read_file_and_size now detects that from st_mode and dispatches to the platform read_raw_device, which reads the whole device; regular files keep the stdio path. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
When URUNIT_CONFIG / URUNIT_DEFROUTE are not in the process environment, consult the kernel boot variables via get_boot_var (used when the kernel passes parameters through its environment, e.g. FreeBSD as init). Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
When urunit is started with no command line (e.g. by the FreeBSD kernel as init), take the application and its arguments from the UCS/UCE section of the configuration (ARC count + verbatim ARV arguments). Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Implement the platform hooks for FreeBSD in src/freebsd.c (console via /dev/console, kenv boot vars, raw virtio config device, network via the routing socket, root remount, tmpfs, subreaper via procctl, reboot) and add the Makefile rule that builds it when TARGET_OS is FreeBSD. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Parse the UNS/UNE section (IP/GW/MSK) and hand it to the platform configure_network hook, for guests that cannot get the network from the kernel command line. No-op on Linux (network comes from ip=). Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Describe the UCS/UCE application-command section and the UNS/UNE network section of the configuration file in the README. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
cmainas
force-pushed
the
feat/freebsd_init
branch
2 times, most recently
from
September 12, 2026 05:48
0ea3a99 to
6e63bda
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a platform-abstraction layer to
urunitand a FreeBSD implementation of it, plus new configuration fields for passing the command arguments and the network config.Until now
urunitwas Linux-only and relied on the Linux kernel to hand over things like the console, the network, and a writable root. However, this is not the case for FreeBSD and all the previously mentioned functionalities are now handled by urunit. The OS-specific pieces are moved behind a small platform interface. Linux and FreeBSD each provide their own implementation, and the shared logic stays free of per-OS branching.On top of that, the configuration can be read from a regular file or straight from a raw device, since FreeBSD does not expose initrd in the same way as Linux.